CCFLAGS=-W -V -I -ansi -Md -c
LDFLAGS=-M -m -d -s

all: picoshell.bin HEPIA.bin compteur.bin

picoshell.bin: picoshell.o syscall_user.o user_lib.o div_asm.o exit.o 

	@echo "----------------------"	
	@echo $@
	ld86 $(LDFLAGS) -o $@ $^

picoshell.o: picoshell.c picoshell.h user_lib.h
	@echo "----------------------"	
	@echo $@
	bcc $(CCFLAGS) -o $@ $<

HEPIA.bin: HEPIA.o syscall_user.o user_lib.o div_asm.o exit.o
	@echo "----------------------"	
	@echo $@
	ld86 $(LDFLAGS) -o $@ $^

HEPIA.o: HEPIA.c picoshell.h user_lib.h
	@echo "----------------------"	
	@echo $@
	bcc $(CCFLAGS) -o $@ $<

compteur.bin: compteur.o syscall_user.o user_lib.o div_asm.o exit.o
	@echo "----------------------"	
	@echo $@
	ld86 $(LDFLAGS) -o $@ $^

compteur.o: compteur.c picoshell.h user_lib.h
	@echo "----------------------"	
	@echo $@
	bcc $(CCFLAGS) -o $@ $<
	
syscall_user.o: syscall_user_asm.s
	@echo "----------------------"	
	@echo $@
	as86 -o $@ $<
	
user_lib.o: user_lib.c user_lib.h syscall_user.h math.h
	@echo "----------------------"	
	@echo $@
	bcc $(CCFLAGS) -o $@ $<

div_asm.o : div_asm.s
	as86 -o $@ $<
	
exit.o: exit_asm.s exit.h
	as86 -o $@ $<

#../kernel/file_handler.o : ../kernel/file_handler.c ../kernel/file_handler.h const.h sectors.h console.h mem.h math.h types.h
#	bcc $(CCFLAGS) -o $@ $<
	
clean:
	@echo "----------------------"	
	@echo $@
	rm -f *.o *.bin *~
